package com.atguigu.gmall.payment.controller;

import com.atguigu.gmall.enums.model.PaymentType;
import com.atguigu.gmall.payment.model.PaymentInfo;
import com.atguigu.gmall.payment.service.PaymentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: atguigu
 * @create: 2023-01-27 20:52
 */
@RestController
@RequestMapping("/api/payment/")
public class PaymentApiController {

    @Autowired
    private PaymentInfoService paymentInfoService;


    /**
     * 查询本地交易记录
     *
     * @param orderId
     * @return
     */
    @GetMapping("/getPaymentInfo/{orderId}")
    public PaymentInfo getPaymentInfo(@PathVariable Long orderId) {
        PaymentInfo paymentInfo = paymentInfoService.getPaymentInfo(orderId, PaymentType.ALIPAY.name());
        if (null != paymentInfo) {
            return paymentInfo;
        }
        return null;
    }
}
